let codeList = document.querySelectorAll(".code");
let inputs = document.querySelectorAll("input");
let len = inputs.length;

inputs.forEach((input, idx) => {
  input.addEventListener("input", () => {
    if (input.value.length !== 0) {
      let len2 = input.value.length;
      codeList[idx].classList.add("no-bac");
      let next = idx === len - 1 ? len - 1 : idx + 1;
      input.value = input.value[len2 - 1];
      input.style.border = "3px solid rgb(0, 187, 255)";
      inputs[next].focus();
    } else {
      codeList[idx].classList.remove("no-bac");
    }
  });
});
